<template>
    <el-dialog
        :close-on-click-modal="false"
        :title="title"
        class="re-dialog tip-dialog"
        :visible.sync="dialogVisible"
        width="700px"
    >
        <div class="table-wrapper">
            <el-table
                :row-class-name="tableRowClassName"
                stripe
                ref="multipleTable"
                :data="tableData"
                tooltip-effect="dark"
                height='600px'
                style="width: 100%;overflow:auto"
                row-key="id"
            >
                <!-- <el-table-column type="selection" width="55"></el-table-column> -->
                <el-table-column
                    :formatter="item.formatter"
                    v-for="(item,index) in config"
                    :key="index"
                    v-bind:prop="item.prop"
                    v-bind:label="item.label"
                ></el-table-column>
            </el-table>
        </div>
    </el-dialog>
</template>

<script>
import Pubsub from "../../utils/pubsub";
import { ZHZXEventInfoQueryRecent, findByDictCode } from "../../config/api";
import { getTimeStr, addScrollEvent } from "../../utils";
export default {
    props: ["list", "total"],
    data() {
        return {
            dialogVisible: false,
            tableData: [],
            config: [],
        };
    },
    created() {
        this.pubsub_token = Pubsub.subscribe("yjAndDbDialog", (type, values = {}) => {
            let { dataList = [],config=[],title='详情' } = values;
            this.tableData = dataList;
            this.config = config;
            this.title = title;
            this.dialogVisible = true;
        });
    },
    destroyed() {
        this.pubsub_token && Pubsub.unsubscribe(this.pubsub_token);
    },
    methods: {
        /**
         * 设置table某一项class
         */
        tableRowClassName({ row, rowIndex }) {
            // if (rowIndex === 2) {
            //   return "warning-row";
            // }
            if (rowIndex % 2 === 0) {
                return "even-row";
            } else {
                return "odd-row";
            }
        }
    }
};
</script>

<style lang = "scss" scoped>
.tip-dialog {
    /* position: relative; */
    /* left:30%; */
    transition: all 0.3s ease-in-out;
    min-height: 30vh;
}
</style>
